package com.gitee.wsl.struct.table.mini.dsl

import com.gitee.wsl.struct.table.mini.Cell

@PicnicDsl
interface CellDsl : CellStyleDsl {
    var columnSpan: Int
    var rowSpan: Int
}

internal class CellDslImpl private constructor(
    private val content: Any?,
    private val cellStyleImpl: CellStyleDslImpl,
) : CellDsl, CellStyleDsl by cellStyleImpl {

    constructor(content: Any?) : this(content, CellStyleDslImpl())

    override var columnSpan: Int = 1
    override var rowSpan: Int = 1

    fun create() = Cell(content?.toString() ?: "") {
        columnSpan = this@CellDslImpl.columnSpan
        rowSpan = this@CellDslImpl.rowSpan
        style = cellStyleImpl.createOrNull()
    }
}